import Vue from 'vue'
import Vuex from 'vuex'
Vue.use (Vuex);

const store = new Vuex.Store({
	// 用来存放数据的对象
	state:{
		// 初始值
		title: '卖座电影',
		flag: false,
	},
	
	// 定义取数据
	getters:{
		title:function(state){
			return state.title;
		},
		flag:(state)=>{
			return state.flag
		}
	},
	mutations: {
			updateTitle: (state,payload)=>{
				state.title = payload;
			},
			isFlag: (state,payload)=>{
				state.flag = payload;
			}
		},
	actions:{
		updateTitle: ({commit},payload)=>{
			commit('updateTitle',payload)
		}
	}
	
});
export default store;
